package com.alphawavesgames.jdroidengine;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import com.alphawavesgames.engine.game.RenderUpdateThread;
import com.alphawavesgames.engine.rendering.GLRenderContainer;
import com.alphawavesgames.engine.rendering.GLRenderHWInterface;
import com.alphawavesgames.engine.rendering.RenderContainer;

/**
 *
 * @author Duncan
 */
public class JAWGLSurfaceView extends GLSurfaceView implements SurfaceHolder.Callback
{

    /** Handle to the application context, used to e.g. fetch drawables */
    private Context m_context;
    RenderContainer m_renderContainer;

    //private GLRenderHWInterface m_renderer;

    public JAWGLSurfaceView( Context context, AttributeSet attrs, GLRenderContainer renderContainer )
    {
        super( context, attrs );

        m_context = context;
        m_renderContainer = renderContainer;

        // register our interest in hearing about changes to our surface
        SurfaceHolder holder = getHolder();
        holder.addCallback( this );

        //create the opengl renderer we want this gl surface view to use
        GLRenderHWInterface renderer = renderContainer.getRenderHWInterface();
        setRenderer( renderer );
    }

    public JAWGLSurfaceView( Context context, GLRenderContainer renderContainer )
    {
        super( context );

        m_context = context;
        m_renderContainer = renderContainer;

        // register our interest in hearing about changes to our surface
        SurfaceHolder holder = getHolder();
        holder.addCallback( this );

        //create the opengl renderer we want this gl surface view to use
        GLRenderHWInterface renderer = renderContainer.getRenderHWInterface();
        setRenderer( renderer );
    }

    //public GLRenderHWInterface getRenderer() { return m_renderer; }

}
